
public class Order {
        private final int id;
        private Chef doer;
        private Waiter waiter;
        private final Consumer consumer;
        private static int orderIncrementalId = 0;

        public synchronized Waiter getWaiter() {
                return waiter;
        }

        public synchronized void setWaiter(Waiter waiter) {
                this.waiter = waiter;
        }

        public Order(Consumer consumer) {
                super();
                this.consumer = consumer;
                synchronized (this.getClass()) {
                        this.id = orderIncrementalId++;
                }
        }

        public synchronized Consumer getConsumer() {
                return consumer;
        }

        public synchronized Chef getDoer() {
                return doer;
        }

        public synchronized void setDoer(Chef doer) {
                this.doer = doer;
        }

        public synchronized int getId() {
                return id;
        }

}
